﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;

/// <summary>
/// Summary description for ApplyInsured
/// </summary>
public class ApplyInsuredDAL
{
    public ApplyInsuredDAL()
    {

    }


    public String Nric { set; get; }
    public int? ApplicationId { set; get; }
    public String FirstName { set; get; }
    public String LastName { set; get; }
    public String Nationality { set; get; }
    public bool? IsMale { set; get; }
    public String MaritalStatus { set; get; }
    public DateTime? Dob { set; get; }
    public String Relationship { set; get; }
    public String Plan { set; get; }
    public String Occupation { set; get; }
    public String Tel { set; get; }
    public bool? LongStay { set; get; }
    public String Mobile { set; get; }
    public String Email { set; get; }
    public String MailingAddress { set; get; }
    public String Postal { set; get; }
    public String Employer { set; get; }
    public String CompanyAddress { set; get; }
    public String Business { set; get; }
    public String NatureOfIllness { set; get; }
    public String NatureDate { set; get; }
    public String ResultOfTreatment { set; get; }
    public String NatureHospital { set; get; } 
    public String ForeseeableIllness { set; get; }
    public String HyperlipidaemiaReading { set; get; }
    public String HyperlipidaemiaDate { set; get; }
    public String HyperlipidaemiaHospital { set; get; }
    public String HighCholesterolLevel { set; get; }
    public String HighCholesterolDate { set; get; }
    public String HighCholesterolHospital { set; get; }
    public decimal? Height { set; get; }
    public decimal? Weight { set; get; }
    public bool? IsSmoker { set; get; } 
    public String Hazardous { set; get; }
    public String TravelFrequency { set; get; }
    public String DeclinedHistory { set; get; }
    public String docPath { set; get; }
    public DateTime? StartDate{ set; get; }
    public DateTime? EndDate{ set; get; }


    public void save(SqlConnection conn)
    {
        string sql = "INSERT APPLICATION_INSURANCE_INSURED (NRIC,applicationInsuranceId, fName, lName,  nationality, gender, marital,birth,  relationship, planType, occupation, telephone, longStay, mobile, email, address, postalCode, employerName, employerAddress, business, illness,startDate,endDate, illDuration, illTreatment, illhospital, DeclinedHistory, foreseeable, bloodPressureIllSystolic, bloodPressureIllDate, bloodPressureIllHospital, HyperlipidaemiaLevel, HyperlipidaemiaDate,HyperlipidaemiaHospital,height,weight,isSmoker,qstHazardous,qstTravelFrequency,docPath) " +
            "VALUES ( " +
        "@NRIC," +
        "@applicationInsuranceId," +
        "@fName," +
        "@lName," +
        "@nationality," +
        "@gender," +
        "@marital," +
        "@birth," +
        "@relationship," +
        "@planType," +
        "@occupation," +
        "@telephone," +
        "@longStay," +
        "@mobile," +
        "@email," +
        "@address," +
        "@postalCode," +
        "@employerName," +
        "@employerAddress," +
        "@business," +  
        "@illness," +
        "@startDate," +
        "@endDate," +
        "@illDuration," +
        "@illTreatment," +
        "@illhospital," +
        "@DeclinedHistory," +
        "@foreseeable," +
        "@bloodPressureIllSystolic," +
        "@bloodPressureIllDate," +
        "@bloodPressureIllHospital," +
        "@hyperlipidaemiaLevel," +
        "@hyperlipidaemiaDate," +
        "@hyperlipidaemiaHospital," +
        "@height," +
        "@weight," +
        "@isSmoker," +
        "@qstHazardous," +
        "@qstTravelFrequency," +
        "@docPath" +
        ")";

        var cmd = new SqlCommand(sql, conn);
        cmd.Parameters.Add(new SqlParameter("@NRIC", (object)Nric ?? DBNull.Value));
        cmd.Parameters.Add(new SqlParameter("@applicationInsuranceId", (object)ApplicationId ?? DBNull.Value));
        cmd.Parameters.Add(new SqlParameter("@fName", (object)FirstName ?? DBNull.Value));
        cmd.Parameters.Add(new SqlParameter("@lName", (object)LastName ?? DBNull.Value));
        cmd.Parameters.Add(new SqlParameter("@nationality", (object)Nationality ?? DBNull.Value));
        cmd.Parameters.Add(new SqlParameter("@gender", (object)IsMale ?? DBNull.Value));
        cmd.Parameters.Add(new SqlParameter("@marital", (object)MaritalStatus ?? DBNull.Value));
        cmd.Parameters.Add(new SqlParameter("@birth", (object)Dob ?? DBNull.Value));
        cmd.Parameters.Add(new SqlParameter("@relationship", (object)Relationship ?? DBNull.Value));
        cmd.Parameters.Add(new SqlParameter("@planType", (object)Plan ?? DBNull.Value));
        cmd.Parameters.Add(new SqlParameter("@occupation", (object)Occupation ?? DBNull.Value));
        cmd.Parameters.Add(new SqlParameter("@telephone", (object)Tel ?? DBNull.Value));
        cmd.Parameters.Add(new SqlParameter("@longStay", (object)LongStay ?? DBNull.Value));
        cmd.Parameters.Add(new SqlParameter("@mobile", (object)Mobile ?? DBNull.Value));
        cmd.Parameters.Add(new SqlParameter("@email", (object)Email ?? DBNull.Value));
        cmd.Parameters.Add(new SqlParameter("@address", (object)MailingAddress ?? DBNull.Value));
        cmd.Parameters.Add(new SqlParameter("@postalCode", (object)Postal ?? DBNull.Value));
        cmd.Parameters.Add(new SqlParameter("@employerName", (object)Employer ?? DBNull.Value));
        cmd.Parameters.Add(new SqlParameter("@employerAddress", (object)CompanyAddress ?? DBNull.Value));
        cmd.Parameters.Add(new SqlParameter("@business", (object)Business ?? DBNull.Value));
        cmd.Parameters.Add(new SqlParameter("@illness", (object)NatureOfIllness ?? DBNull.Value));
        cmd.Parameters.Add(new SqlParameter("@illDuration", (object)NatureDate ?? DBNull.Value));
        cmd.Parameters.Add(new SqlParameter("@illTreatment", (object)ResultOfTreatment ?? DBNull.Value));
        cmd.Parameters.Add(new SqlParameter("@illhospital", (object)NatureHospital ?? DBNull.Value));
        cmd.Parameters.Add(new SqlParameter("@DeclinedHistory", (object)DeclinedHistory ?? DBNull.Value));
        cmd.Parameters.Add(new SqlParameter("@foreseeable", (object)ForeseeableIllness ?? DBNull.Value));
        cmd.Parameters.Add(new SqlParameter("@bloodPressureIllSystolic", (object)HyperlipidaemiaReading ?? DBNull.Value));
        cmd.Parameters.Add(new SqlParameter("@bloodPressureIllDate", (object)HyperlipidaemiaDate ?? DBNull.Value));
        cmd.Parameters.Add(new SqlParameter("@bloodPressureIllHospital", (object)HyperlipidaemiaHospital ?? DBNull.Value));
        cmd.Parameters.Add(new SqlParameter("@hyperlipidaemiaLevel", (object)HighCholesterolLevel ?? DBNull.Value));
        cmd.Parameters.Add(new SqlParameter("@hyperlipidaemiaDate", (object)HighCholesterolDate ?? DBNull.Value));
        cmd.Parameters.Add(new SqlParameter("@hyperlipidaemiaHospital", (object)HighCholesterolHospital ?? DBNull.Value));
        cmd.Parameters.Add(new SqlParameter("@height", (object)Height ?? DBNull.Value));
        cmd.Parameters.Add(new SqlParameter("@weight", (object)Weight ?? DBNull.Value));
        cmd.Parameters.Add(new SqlParameter("@isSmoker", (object)IsSmoker ?? DBNull.Value));
        cmd.Parameters.Add(new SqlParameter("@qstHazardous", (object)Hazardous ?? DBNull.Value));
        cmd.Parameters.Add(new SqlParameter("@qstTravelFrequency", (object)TravelFrequency ?? DBNull.Value));
        cmd.Parameters.Add(new SqlParameter("@docPath", (object)docPath ?? DBNull.Value));
        cmd.Parameters.Add(new SqlParameter("@startDate",StartDate));
        cmd.Parameters.Add(new SqlParameter("@endDate",EndDate ));

        cmd.CommandType = CommandType.Text;
        cmd.ExecuteNonQuery();

    }

}